package cn.xyy.common.domain.system.auth;

import java.util.List;

/**
 * 系统权限VO
 * 
 * @author xyy
 *
 */
public class PermissionVO {

	private String id;
	private String parentId;

	private String title;

	private String permissionCode; // 权限标识

	private Integer types; // 0目录 '1:菜单，2:按钮',

	private Integer status;

	private String description;

	private String path;

	private Integer levels;
	private Integer sorts;

	private Integer iframe;// 是否外链 2不是，1是

	private String name;// 组件名称

	private String component;// 组件路径

	private String icon;// 图标

	private Integer cache;// 是否缓存 2:不是 1是

	private String redirect;// 跳转
	private Integer hide;// 隐藏菜单

	private Integer hideChildren;// 隐藏所有子菜单

	// 子权限集合
	private List<PermissionVO> children;

	public boolean isMenu() {
		if (this.types == 0 || this.types == 1) {
			return true;
		}
		return false;
	}

	public boolean isRoot() {
		if ("0".equals(this.parentId)) {
			return true;
		}
		return false;
	}

	public boolean isPermission() {
		if (this.types == 2) {
			return true;
		}
		return false;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<PermissionVO> getChildren() {
		return children;
	}

	public void setChildren(List<PermissionVO> children) {
		this.children = children;
	}

	public String getId() {
		return id;
	}

	public PermissionVO setId(String id) {
		this.id = id;
		return this;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public Integer getTypes() {
		return types;
	}

	public void setTypes(Integer types) {
		this.types = types;
	}

	public Integer getLevels() {
		return levels;
	}

	public void setLevels(Integer levels) {
		this.levels = levels;
	}

	public Integer getSorts() {
		return sorts;
	}

	public void setSorts(Integer sorts) {
		this.sorts = sorts;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime * result + ((types == null) ? 0 : types.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PermissionVO other = (PermissionVO) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (types == null) {
			if (other.types != null)
				return false;
		} else if (!types.equals(other.types))
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		return true;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Integer getIframe() {
		return iframe;
	}

	public void setIframe(Integer iframe) {
		this.iframe = iframe;
	}

	public Integer getCache() {
		return cache;
	}

	public void setCache(Integer cache) {
		this.cache = cache;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPermissionCode() {
		return permissionCode;
	}

	public void setPermissionCode(String permissionCode) {
		this.permissionCode = permissionCode;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getComponent() {
		return component;
	}

	public void setComponent(String component) {
		this.component = component;
	}

	public String getRedirect() {
		return redirect;
	}

	public void setRedirect(String redirect) {
		this.redirect = redirect;
	}

	public Integer getHide() {
		return hide;
	}

	public void setHide(Integer hide) {
		this.hide = hide;
	}

	public Integer getHideChildren() {
		return hideChildren;
	}

	public void setHideChildren(Integer hideChildren) {
		this.hideChildren = hideChildren;
	}

}